package com.ideafactory.client.utils;

import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.ideafactory.client.ybservice.APP;
import com.ideafactory.client.ybselfservice.R;

/**
 * Created by LiuShao on 2016/5/9.
 */
public class HintViewUtils {

    private static Toast toast;
    public static void showMyToast(String toastString,int layoutId){
        if(toast!=null){
            toast.cancel();
        }
        toast = new Toast(APP.getAPP().getApplicationContext());
        View view = View.inflate(APP.getAPP().getApplicationContext(), R.layout.show_toast, null);
        TextView tv_toast = (TextView) view.findViewById(R.id.tv_show_toast);
        ImageView iv_toast = (ImageView) view.findViewById(R.id.image_show_toast);
        tv_toast.setText(toastString);
        if(layoutId!=-1){
            iv_toast.setImageResource(layoutId);
        }
        toast.setView(view);
        toast.setGravity(Gravity.CENTER, 0,0);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.show();
    }

}
